/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.view;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Juan Carlos
 */
@ManagedBean
@RequestScoped
public class AccesBean {

    private String user;
    private String password;

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Creates a new instance of AccesBean
     */
    public AccesBean() {
    }

    //---Actions---//
    public String procesarAction() {
        //Metodo de findByUserAndPass
        if (user.equals("root") && password.equals("12345")) {
            FacesContext context = FacesContext.getCurrentInstance();
            context.getExternalContext().getSessionMap().put("Logged User", user);
            return "PrincipalMenu";
        } else {
            return "pagina2";
        }
    }
}
